package com.htudata.hieyes.flow.controller;

import com.htudata.common.enums.RequestSeqEnum;
import com.htudata.common.enums.RequestStatusEnum;
import com.htudata.convention.domain.ResponseResult;
import com.htudata.core.util.ResultGenerator;
import com.htudata.hieyes.flow.service.FlowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class FlowController {

  @Autowired
  private FlowService flowService;
  
  @GetMapping({"/v1/flow/flowMonitorNodeData"})
  public ResponseResult getFlowData(String flowId) {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_026.getCode(), this.flowService.getMonitorNodeData(flowId));
    } catch (Exception e) {
      log.error("getFlowData", e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_026.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
}
